package net.neptech.controller;

import net.neptech.dto.schedule.ScheduleDto;
import net.neptech.model.schedule.Schedule;
import net.neptech.service.ScheduleService;
import net.neptech.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * @Author HuangZhengmin
 * @desc
 * @Date 2025/8/15 11:39
 * @Version 1.0
 */
@RestController
@RequestMapping("schedule/schedule")
public class ScheduleController {
  @Autowired
  private ScheduleService scheduleService;

  /**
   * 批量新增Schedule
   * @param scheduleDto
   * @return
   */
  @PostMapping
  public ResponseResult batchAddSchedule(@RequestBody ScheduleDto scheduleDto) {
    scheduleService.batchAddSchedule(scheduleDto);
    return ResponseResult.success();
  }

  /**
   * 批量新增或更新Schedule
   * @param scheduleDto
   * @return
   */
  @PostMapping("/batch-save-or-update")
  public ResponseResult batchSaveOrUpdateSchedules(@RequestBody ScheduleDto scheduleDto) {
    scheduleService.batchAddOrUpdateSchedule(scheduleDto);
    return ResponseResult.success();
  }

  /**
   * 根据条件查询Schedule
   * @param condition
   */
  @PostMapping("/search")
  public ResponseResult<List<Schedule>> searchSchedules(@RequestBody Schedule condition) {
    return ResponseResult.success(scheduleService.findSchedulesByCondition(condition));
  }

  /**
   * 根据scheduleId删除Schedule
   */
  @DeleteMapping("/{scheduleId}")
  public ResponseResult deleteScheduleById(@PathVariable("scheduleId") Long scheduleId) {
    scheduleService.deleteSchedule(scheduleId);
    return ResponseResult.success();
  }
}
